feat: openapi refactor#1562
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive API client layer and a corresponding CLI interface for SwanLab. It includes a base entity class for handling HTTP requests safely, a set of type definitions for various API resources (experiments, projects, users, etc.), and utility functions for data transformation. The CLI is expanded with an api command group to allow direct interaction with these resources. Feedback focuses on correcting typos in type definitions and file headers, ensuring all CLI subcommands are properly imported and registered, and removing redundant logic in the API response handling.
95c68d7 to
4806400
Compare
Usage::
from swanlab.api import FilterOperation as FOP
runs = project.runs(filters=[
FOP.state == "FINISHED",
FOP.createdAt >= "2025-03-25",
FOP.createdAt <= datetime(2025, 3, 25, 23, 59, 59),
FOP("lr", type="CONFIG") >= 0.1,
FOP.state.in_("RUNNING", "FINISHED"),
])
Attribute access (``F.state``) auto-detects STABLE keys.
For CONFIG / SCALAR fields use call syntax: ``F("key", type="CONFIG")``.或者按照原本的运算符扩展 |
ca80b03 to
d9c4472
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Object-Oriented API layer and corresponding CLI subcommands for querying SwanLab entities such as projects, experiments, and metrics. The implementation includes robust validation logic, safe HTTP request handling, and extensive unit tests. Feedback focuses on optimizing performance by reducing redundant API calls in entity data loading and metric fetching, correcting a typo in a utility function name, and improving the library's logging and pagination behavior to ensure a better user experience.
|
/gemini review |
1 similar comment
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements a new OOP-based public API package and corresponding CLI commands for SwanLab, enabling users to interact with workspaces, projects, experiments, and metrics. The architecture utilizes a base entity class to provide safe HTTP requests and lazy data loading. Key feedback includes addressing performance bottlenecks caused by hardcoded sleep intervals in pagination and sequential network requests for CSV exports. Additionally, the property extraction utility needs refinement to correctly handle nested containers and non-builtin types for reliable JSON serialization.
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive Object-Oriented API layer and corresponding CLI commands for querying SwanLab data, including workspaces, projects, experiments, columns, and metrics. The implementation features a base entity class with safe HTTP request handling, detailed type definitions, and unit tests. Review feedback identifies several logic and performance issues: the hardcoded sleep in the pagination logic should be made configurable to avoid efficiency bottlenecks, a logic error in the Column.metric method where the metric_type parameter is overwritten needs to be addressed, the sample parameter is currently not being included in the scalar metric request payloads, and the recursive property extraction utility requires enhancement to correctly handle container types and common non-builtin objects like datetimes.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive OOP-style public API and CLI for SwanLab, enabling programmatic access to workspaces, projects, experiments, and metrics. While the implementation provides a structured interface for data retrieval, the review identifies several critical areas for improvement regarding robustness and performance. Specifically, the pagination logic silently terminates on errors, hardcoded delays unnecessarily slow down large data fetches, and failed requests are permanently cached as empty data states. Additionally, the reviewer recommended using key-based mapping for metric data to avoid order-dependency and suggested a more robust serialization approach for complex nested properties.
This reverts commit 6b7b7c7.
Description
swanlab api [project/run/..]和SwanLab.Api()双格式调用